package sistkaraoke.servlet.ReservaDeSalas;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import sistkaraoke.modelo.IPersona;
import sistkaraoke.modelo.ISala;
import sistkaraoke.negocio.GestionSalas;
import sistkaraoke.negocio.IGestionSalas;

/**
 * Servlet implementation class ListarReservarSalaServlet
 */
@WebServlet("/ListarReservarSalaServlet")
public class ListarReservarSalaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListarReservarSalaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		try {			
			
			String stIdlocal = request.getParameter("local").trim();
			
			int IDlocal = 0;
			
			if (stIdlocal.length() > 0) 
				IDlocal= Integer.parseInt(stIdlocal);
			
			IGestionSalas negocio = new GestionSalas();
			
			request.setAttribute("salas_disponibles",((Collection<ISala>) negocio.ListarSalaDisponible(IDlocal)));
						
			request.setAttribute("IdLocalSelected", stIdlocal.toString());
			RequestDispatcher rd = request.getRequestDispatcher("ReservarSala.jsp");
			
			rd.forward(request, response);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}
}
